package bio_nio_aio.bio.com_base.file;

import java.io.FileInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class TEPClient {
	public static void main(String[] args) throws Exception {

		FileInputStream fis = new FileInputStream("D:\\My websit\\images\\my food\\food3.jpg");

		Socket socket = new Socket("127.0.0.1",8888);

		OutputStream os = socket.getOutputStream();

		byte[] bytes = new byte[1024];
		int len = 0;
		while((len = fis.read(bytes))!=-1){
			os.write(bytes, 0, len);
		}
		//为其输出流中加上 "终止符"  ！= -1 这里写入的时候把终止符写掉了
		socket.shutdownOutput();

		//这里是在读取返回来的信息
		InputStream is = socket.getInputStream();
		while((len = is.read(bytes))!=-1){
			System.out.print(new String(bytes,0,len));
		}

		fis.close();
		socket.close();
	}
}